import { dataSourceType } from "@/type";
const checkForm = async (_rule: dataSourceType = {}, value: any,) => {
  if (_rule.required) {
    // 必填项验证非空并排除非必须项
    console.log(_rule, value, '_rule, value')
    if ((value === '' || value === undefined)) {
      return Promise.reject(`${_rule.msg1}`);
    } else {

      return Promise.resolve();
    }
  } else {
    return Promise.resolve();
  }
};
import rules from "../../../../utils/rules";
// isBoolean:true, // 是否为Boolean类型, 参数是否必须为boolen类型，不是根据options个数判断，是根据后台字段类型要求判断
const comSelectCfg = {
  value: "",
  placeholder: "请选择",
  param: "",
  rule: {
    required: true,
    validator: checkForm,
    trigger: ["change"],
    msg1: "此项必选",
    msg2: "",
    api: "",
    key: "siteDomain",
    params: {}, //校验传参
  },
  label: "",
  title: "",
  extra: "",
  beforeText: "",
  afterText: "",
  type: "multipleSelect",
  options: [],
  mode: "single",
  associated: "",
  associatedValue: "",
}
const tplForm = {
  PC: {
    templateDir: '',
    homeTpl: '',
    formState: [
      {
        value: "模板方案",
        type: "title",
        id: "contentSetup",
        params: 'tpl',
        children: [Object.assign({}, comSelectCfg, {
          label: '模板方案：',
          param: 'templateDir',
          placeholder: "请选择",
        })],
      },

      {
        value: "首页模板",
        type: "title",
        id: "waterMarkSetup",
        children: [Object.assign({}, comSelectCfg, {
          label: '首页模板：',
          param: 'homeTpl',
          placeholder: "请选择",
        })],
      },

      {
        value: "栏目模型对应模板",
        type: "title",
        id: "channelSetUp",
        children: [],
      },
      {
        value: "内容模型对应模板",
        type: "title",
        id: "contentSetup",
        children: [],
      },
      {
        value: "全局内容模型",
        type: "title",
        id: "contentSetup",
        children: [],
      },
    ]

  },
  Mobile: {
    templateDir: '',
    homeTpl: '',
    formState: [
      {
        value: "模板方案",
        type: "title",
        id: "contentSetup",
        params: 'tpl',
        children: [Object.assign({}, comSelectCfg, {
          label: '模板方案：',
          param: 'templateDir',
          placeholder: "请选择",
        })],
      },

      {
        value: "首页模板",
        type: "title",
        id: "waterMarkSetup",
        children: [Object.assign({}, comSelectCfg, {
          label: '首页模板：',
          param: 'homeTpl',
          placeholder: "请选择",
        })],
      },

      {
        value: "栏目模型对应模板",
        type: "title",
        id: "channelSetUp",
        children: [],
      },
      {
        value: "内容模型对应模板",
        type: "title",
        id: "contentSetup",
        children: [],
      },
      {
        value: "全局内容模型",
        type: "title",
        id: "contentSetup",
        children: [],
      },
    ]
  }

};
export { comSelectCfg, tplForm };
